#ifndef __W25Q256_H
#define __W25Q256_H
#include "stm32f4xx.h"
#define W25X_WriteEnable          0x06
#define W25X_WriteDisable         0x04
#define W25X_ReadStatusReg        0x05
#define W25X_WriteStatusReg     	0x01
#define W25X_ReadData             0x03
#define W25X_FastReadData         0x0B
#define W25X_FastReadDual         0x3B
#define W25X_PageProgram          0x02
#define W25X_BlockErase           0xD8
#define W25X_SectorErase          0x20
#define W25X_ChipErase            0xC7
#define W25X_PowerDown            0xB9
#define W25X_ReleasePowerDown     0xAB
#define W25X_DeviceID             0xAB
#define W25X_ManufactDeviceID     0x90
#define W25X_JedecDeviceID        0x9F
#define W25X_Enter4ByteMode       0xB7
#define W25X_ReadStatusRegister3      0x15

#define WIP_Flag                  0x01
#define Dummy_Byte                0xFF

#define W25XX_NSS_HIGH            GPIO_SetBits(SPI5_GPIO_PORT, SPI5_NSS_PIN)
#define W25XX_NSS_LOW             GPIO_ResetBits(SPI5_GPIO_PORT, SPI5_NSS_PIN)
#define W25Q256_PageSize              256
#define W25Q256_PerWritePageSize      256
void W25Q256_Init(void);
void W25Q256_SectorErase(u32 SectorAddr);
void W25Q256_BulkErase(void);
void W25Q256_PageWrite(u8* pBuffer, u32 WriteAddr, u32 NumByteToWrite);
void W25Q256_BufferWrite(u8* pBuffer, u32 WriteAddr, u32 NumByteToWrite);
void W25Q256_BufferRead(u8* pBuffer, u32 ReadAddr, u32 NumByteToRead);
u32 W25Q256_ReadID(void);
u32 W25Q256_ReadDeviceID(void);
void W25Q256_StartReadSequence(u32 ReadAddr);
void W25Q256_PowerDown(void);
void W25Q256_WAKEUP(void);
void W25Q256_Mode_Init(void);

u16 W25Q256_SendHalfWord(u16 HalfWord);
void W25Q256_WriteEnable(void);
void W25Q256_WaitForWriteEnd(void);
#endif
